function [L,normError] = CholeskyBlockLeftComplex(matrixSize,blockSize,A)
L = A
fprintf(1,'\n\nCHOLESKY LEFT: INIZIO CALCOLO\n\n');
for k=1:blockSize:matrixSize
    %k
    %fprintf(1, 'Faccio gli aggiornamenti per l''elemento diagonale %d %d: \n', k/blockSize, k/blockSize);   
    for i=1:blockSize:k-blockSize
        %Lkk = Lkk - Lki * LTki
        fprintf(1, '\nL%d%d = L%d%d - L%d%d * LT%d%d \n', k/blockSize, k/blockSize, k/blockSize, k/blockSize, k/blockSize, i/blockSize, k/blockSize, i/blockSize);
        trasp = L(k:k+blockSize-1,i:i+blockSize-1)';
        mult = L(k:k+blockSize-1,i:i+blockSize-1) * trasp;
        L(k:k+blockSize-1,k:k+blockSize-1) = L(k:k+blockSize-1,k:k+blockSize-1) - mult;
        fprintf(1, 'Risultato: \n');
        L(k:k+blockSize-1,k:k+blockSize-1)
    end
    %Estrae la sottomatrice della diagonale e ne calcola la fattorizzazione
    %correzione della diagonale
    for c=k:matrixSize
%         correction = zeros(matrixSize-c,matrixSize-c);
%         correction(c,c) = imag(L(c,c));
%         normError = norm(correction);
        L(c,c) = real(L(c,c));
    end
    if (k == 1) 
        fprintf(1, 'k = %d Matrice che vado per fattorizzare\n', k);
        L(k:k+blockSize-1,k:k+blockSize-1)
    end
    fprintf(1, '\nL%d%d = chol(L%d%d)\n', k/blockSize, k/blockSize, k/blockSize, k/blockSize);
    temp=chol(L(k:k+blockSize-1,k:k+blockSize-1),'lower');
    L(k:k+blockSize-1,k:k+blockSize-1) = temp; %Scrive la parte appena computata nella matrice L
    fprintf(1, 'Risultato: \n');
    L(k:k+blockSize-1,k:k+blockSize-1)
    for j=k+blockSize-1:blockSize:matrixSize-blockSize
        for i = 1:blockSize:k-1
            %Ljk = Ljk - Lji * LTki
            fprintf(1, '\nL%d%d = L%d%d - L%d%d * LT%d%d \n', j/blockSize, k/blockSize, j/blockSize, k/blockSize, j/blockSize, i/blockSize, k/blockSize, i/blockSize);
            trasp = L(k:k+blockSize-1,i:i+blockSize-1)';
            mult = L(k:k+blockSize-1,i:i+blockSize-1)*trasp;
            L(j:j+blockSize-1,k:k+blockSize-1) = L(j:j+blockSize-1,k:k+blockSize-1) - mult;
            fprintf(1, 'Risultato: \n');
            L(j:j+blockSize-1,k:k+blockSize-1)
        end
        %Ljk = Ljk * LTkk^-1
        fprintf(1, '\nL%d%d = L%d%d * LT%d%d^-1\n', j/blockSize, k/blockSize, j/blockSize, k/blockSize, k/blockSize, k/blockSize);
        invert = inv(L(k:k+blockSize-1,k:k+blockSize-1));
        trasp = (invert)';
        L(j:j+blockSize-1,k:k+blockSize-1) = L(j:j+blockSize-1,k:k+blockSize-1) * trasp;
        fprintf(1, 'Risultato: \n');
        L(j:j+blockSize-1,k:k+blockSize-1)
    end
  
end
fprintf(1, 'Risultato finale della fattorizzazione: \n');
L = tril(L)
%L
%errore percentuale
%diff = tril((L - C)./C)
%fprintf(1,'\n\nFINE CALCOLO\n\n');
end